<?php

use App\Blog;
use App\Member;
use App\Cate;
use App\Tag;
use App\Admin;
use Faker\Generator as Faker;

// $faker = app(Faker\Generator::class);
$factory->define(Admin::class, function (Faker $faker) {
    $password = config('fakedata.password');
    $avatar = $faker->randomElement(config('fakedata.avatar'));
    $nickname = $faker->randomElement(config('fakedata.nickname'));
    $mobile = $faker->randomElement(config('fakedata.mobile'));
    return [
        'nickname' => $nickname, 
        'mobile'   => $mobile, 
        'email'    => $faker->unique()->email, 
        'password' => bcrypt($password), 
        'avatar'   => $avatar, 
    ];
});

$factory->define(Cate::class, function (Faker $faker) {
    return [
        'cate_name' => '', 
        'sort' => '', 
    ];
});

$factory->define(Tag::class, function (Faker $faker) {
    return [
        'tag_name' => '', 
        'sort' => '', 
    ];
});

$factory->define(Blog::class, function (Faker $faker) {
    $name = $faker->name;
    $email = $faker->safeEmail;
    $age = $faker->numberBetween(8, 80); //取出范围内的数字
    $city = $faker->city;
    $created_at = $faker->dateTimeBetween('-3 year', '-1 year');
    $text = $faker->text(50);
    $realText =$faker->realText($faker->numberBetween(10, 20));
    $one = $faker->randomElement(['11', '22', '33']); //随机取出一个
    $paragraphs = $faker->paragraphs(4, true); // 段落
    $img = 'http://placeimg.com/640/480/any'; //图片
    $uuid = $faker->uuid();
    $bool = $faker->boolean(); //布尔值


    return [
        'user_id'    => $faker->randomDigit, 
        'cate_id'    => $faker->randomElement(range(1, 10)), 
        'title'      => $faker->title, 
        'content'    => 'Array to string conversion (SQL: insert into `blogs` (`user_id`, `cate_id`, `title`, `content`, `audit_type`, `audit_id`, `updated_at`, `created_at`) values (4, 3, 夫人, Quia animi sint excepturi doloribus aut distinctio molestias. Et quas harum distinctio dolores velit ipsam. Consequatur quia deserunt dicta fuga consequatur. Expedita vitae voluptatem et soluta officia autem. Quis ad magnam sit quia corporis fugiat exercitationem expedita., 已审核, 3, 2021-12-12 12:43:03, 2021-12-12 12:43:03))', 
        'audit_type' => $faker->randomElement(['未审核', '已审核', '未通过']),
        'audit_id'   => $faker->randomElement(range(1, 10)),
    ];
});

$factory->define(Member::class, function (Faker $faker) {
    $nickname = $faker->randomElement(config('fakedata.nickname'), 1);
    $mobile = $faker->randomElement(config('fakedata.mobile'), 1);
    $gender = $faker->randomElement([0, 1, 2]);
    $age = $faker->randomElement(range(18, 40));
    $avatar = $faker->randomElement(config('fakedata.avatar'), 1);
    $phrase = $faker->randomElement(config('fakedata.phrase'), 1);
    return [
        'nickname' => $nickname, 
        'mobile' => $mobile, 
        'email' => $faker->unique()->email, 
        'password' => bcrypt('123456'), 
        'gender' => $gender, 
        'age' => $age, 
        'avatar' => $avatar, 
        'phrase' => $phrase, 
    ];
});

